< previous page page_181 next page >

Page 181
e10a6a0a59f035e870d90cca05b85fce.gif
Dim g_scale As Single
Dim b_scale As Single
Dim r_diff As Integer
Dim g_diff As Integer
Dim b_diff As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
Dim X As Integer
Dim Y As Integer

    ' Get the pixels from picOriginal.
    GetBitmapPixels picOriginal, pixels, bits_per_pixel

    ' Get the middle values for the components.
    r_mid = (MaxIndex(0) + MinIndex(0)) / 2
    g_mid = (MaxIndex(1) + MinIndex(1)) / 2
    b_mid = (MaxIndex(2) + MinIndex(2)) / 2

    Calculate the scale factors needed to resize
    ' the color values.
    r_scale = hbarBrightness.value / _
        (MaxIndex(0) - MinIndex(0))
    g_scale = hbarBrightness.value / _
        (MaxIndex(1) - MinIndex(1))
    b_scale = hbarBrightness.value / _
        (MaxIndex(2) - MinIndex(2))

    ' Set the colors for each component separately.
    For Y = 0 To picOriginal.ScaleHeight - 1
        For X = 0 To picOriginal.ScaleWidth - 1
            With pixels(X, Y)
                r_diff = .rgbRed - r_mid
                r_diff = r_diff * r_scale
                r = 127 + r_diff
                If r < 0 Then r = 0
                If r > 255 Then r = 255
                .rgbRed = r

                g_diff = .rgbGreen - g_mid
                g_diff = g_diff * g_scale
                g = 127 + g_diff
                If g < 0 Then g = 0
                If g > 255 Then g = 255
                .rgbGreen = g

                b_diff = .rgbBlue - b_mid
                b_diff = b_diff * b_scale
                b = 127 + b_diff
                If b < 0 Then b = 0
                If b > 255 Then b = 255

 
< previous page page_181 next page >